@extends('public')
@section('content')
<div class="wrap">
    <div class="main_user">
        <div class="main_L" >
            <div class="side_box">
                <div class="user_pic"><img src="{{asset('images/user_pic.jpg')}}" width="80" height="80" /></div>
                <div class="user_name">您好！{{$user->name}}</div>
                <div class="side_nav">
                    <ul>
                        <li>
                            <a href="{{url('user/myinformation')}}"><span>个人资料</span></a>
                        </li>
                        <li>
                            <a href="{{url('user/myorderform')}}"><span>我的订单</span></a>
                        </li>
                        <li>
                            <a href="{{url('user/address')}}"><span>地址管理</span></a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>

        <div class="main_R">

            <div class="pro_form">
                <form action="{{url('user/myinformation/'.$user->id)}}" method="POST">
                    {{ csrf_field() }}
                    <dl>
                        <dt class="dt_u">当前头像：</dt>
                        <dd>
                            <div class="u_pic">
                                <img src="{{asset('images/user_pic.jpg')}}" width="80" height="80" />
                            </div>
                        </dd>
                        {{--<dd class="uploadimg" >--}}
                            {{--@foreach($news->img as $key=>$images)--}}
                            {{--<span>--}}
                                {{--<input type="hidden" name="img[]" value="}">--}}
                                {{--<a href="javascript:void(0);"></a>--}}
                            {{--</span>--}}
                            {{--<a href="javascript:;" id="pickfiles" class="pickfiles" title="选择上传文件">--}}
                                {{--<img src="" onerror="this.src='{{url("images/defaltPic.jpg")}}'" width="80" height="80"/>--}}
                            {{--</a>--}}
                        {{--</dd>--}}
                    </dl>

                        <dt>昵称：</dt>
                        <dd><input class="input" name="nickName" type="text" value="{{$user->nickName}}" /></dd>
                    </dl>
                    <dl>
                        <dt>性别：</dt>
                        <dd>
                            <input name="sex" type="radio" @if($user->sex == 'm') checked="checked" @endif  value="m">
                            <span class="t_sex">男</span>
                            <input name="sex" type="radio"  @if($user->sex == 'f') checked="checked" @endif  value="f">
                            <span class="t_sex">女</span></dd>
                    </dl>
                    <dl>
                        <dt>手机：</dt>
                        <dd><input class="input" name="mobile" type="text" value="{{$user->mobile}}" /></dd>
                    </dl>
                    <dl>
                        <dt>邮箱：</dt>
                        <dd><input class="input" name="email" type="text" value="{{$user->email}}" /></dd>
                    </dl>
                    {{--<dl>--}}
                        {{--<dt>地址：</dt>--}}
                        {{--<dd><input class="input" name="address" type="text" value="{{$user->address}}" /></dd>--}}
                    {{--</dl>--}}
                    <dl>
                        <dt>&nbsp;</dt>
                        <dd>
                            <input class="btn" name="" type="submit" value="确认" />
                        </dd>
                    </dl>
                    <div class=" clear"></div>
                </form>
            </div>

        </div>

        <div class="clear"></div>
    </div>
</div>
@stop
@section('js')
    <script type="text/javascript" language="JavaScript">
//        添加成功后来个弹出框
        $(function(){
            var message = '{{session('message')}}';
            if(message){
                alert(message);
            }
        });
    </script>
    <script>
        $(function () {
            var uploader = new plupload.Uploader({
                runtimes: 'html5,flash,silverlight,html4',
                browse_button: 'pickfiles', // you can pass in id...
                //container: document.getElementById('container'), // ... or DOM Element itself
                url: "{{ url('upimg') }}",
                filters: {
                    max_file_size: '10mb',
                    mime_types: [
                        {title: "Image files", extensions: "jpg,gif,png"}
                    ]
                },
                multi_selection: false,
                file_data_name: 'file',
                multipart_params: {'_token': '{{ csrf_token() }}', 'dir': 'news'},
                // Flash settings
                flash_swf_url: '{{ asset("js/plupload/Moxie.swf") }}',
                // Silverlight settings
                silverlight_xap_url: '{{ asset('js/plupload/Moxie.xap') }}',

                init: {
                    PostInit: function () {
                        return false;
                    },
                    FilesAdded: function (up, file) {
                        $('.up-pic img').attr('src', '{{ asset('images/loading.gif') }}');
                        uploader.start();
                    },
                    Error: function (up, err) {
                        tips(err.message);
                    },
                    FileUploaded: function (up, file, responseObj) {
                        var response = $.parseJSON(responseObj.response);
                        if (response.state == 'success') {
                            var　imgString = '<span><img title="图片" src="' + response.src + '"/><input type="hidden" name="img[]" value="' + response.src + '"/><a href="javascript:void(0);">X</a></span>';
                            $(".u_pic").prepend(imgString);

                        } else {
                            tips(response.message);
                        }
                    }
                }
            });
            uploader.init();

            $(".u_pic").on("click", "span a", function(){
                $(this).parent().remove();
            });

        });

    </script>
@endsection
